package org.mihalovic.PES.GUI;

import java.util.ArrayList;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;



/**
 * TableRowElement instances are intended to be data elements in JTable (are used in its TableModel).
 */
class TableRowElement {
//del    private String domainId;

    private boolean selected;
    private String domainName;
    private int ratingsInDomain;

    ArrayList<ChangeListener> changeListeners;

//del    public String DomainID()      { return domainId; }              //TODO: CAN'T have this!!!
    public String DomainName()    { return domainName; }
    public int RatingsInDomain()  { return ratingsInDomain; }
    public boolean isSelected()   { return selected; }
    public void setSelected(boolean selected) {
        this.selected=selected;

        if(changeListeners.isEmpty())
            return;
        for(ChangeListener l : changeListeners)
            l.stateChanged(new ChangeEvent(this));
    }

    public TableRowElement(/*String domainId, */String domainName, int ratingsInDomain) {
//del        this.domainId = domainId;               //TODO: no!
        this.domainName = domainName;
        selected=false;
        this.ratingsInDomain = ratingsInDomain;
        changeListeners = new ArrayList<ChangeListener>();
    }

    public void addChangeListener(ChangeListener listener) {
        changeListeners.add(listener);
    }
}
